'''
Created on 5. tra. 2011.

@author: Ana Banana
'''

nodes = {};
edges = [];

class Network :
    
    def __init__(self, name):
        self.name = name;
    
    def add_node (self, node):
        if nodes.has_key(node.get_dip_id()):
            return False;
        else:
            nodes[node.get_dip_id()] = node;
            return True;
    
    def add_edge (self, edge):
        edges.append(edge);
        
    def get_nodes (self):
        return nodes
        
    def get_sorted_nodes (self):
        node_list = nodes.values();
        node_dir = {};
        for node in node_list:
            node_dir[node.get_id()] = node;
        node_list = [];
        for i in sorted(node_dir.keys()):
            node_list.append(node_dir.get(i));
        return node_list;
    
    def get_edges (self):
        return edges;